package com.huadao.cart_ccs.data.task;

import com.huadao.cart_ccs.greendao.entity.LiquidLoopPlan;

import java.io.Serializable;

/**
 * 换液任务
 */
public class ChangeLiquidTask extends OperateTask implements Serializable {
    private static final long serialVersionUID = 6003494751438614464L;
    private LiquidLoopTask inputLiquidTask;
    private LiquidLoopTask wasteTask;
    private int amount;//进液体积
    private int wasteAmount;//排液体积

    private int fluidSpeed;
    private int WasteSpeed;

    private ChangeLiquidBO changeLiquidBO;
    private int currentChangeTurn;//目前在第几论置换,从1开始，0代表未开始
    private int currentChangeIndex;//目前在第几次置换，从1开始，0代表未开始
    private Thread thread;

    //执行的计划任务
    private LiquidLoopPlan liquidLoopPlan;

    private int liquidType;

    private boolean isTerminate;

    public ChangeLiquidTask() {
    }

    public ChangeLiquidTask(int amount) {
        this.amount = amount;
    }

    public LiquidLoopTask getInputLiquidTask() {
        return inputLiquidTask;
    }

    public void setInputLiquidTask(LiquidLoopTask inputLiquidTask) {
        this.inputLiquidTask = inputLiquidTask;
    }

    public LiquidLoopTask getWasteTask() {
        return wasteTask;
    }

    public void setWasteTask(LiquidLoopTask wasteTask) {
        this.wasteTask = wasteTask;
    }

    public int getAmount() {
        return amount;
    }

    public void setAmount(int amount) {
        this.amount = amount;
    }

    public int getWasteAmount() {
        return wasteAmount;
    }

    public void setWasteAmount(int wasteAmount) {
        this.wasteAmount = wasteAmount;
    }

    public int getFluidSpeed() {
        return fluidSpeed;
    }

    public void setFluidSpeed(int fluidSpeed) {
        this.fluidSpeed = fluidSpeed;
    }

    public int getWasteSpeed() {
        return WasteSpeed;
    }

    public void setWasteSpeed(int wasteSpeed) {
        WasteSpeed = wasteSpeed;
    }

    public LiquidLoopPlan getLiquidLoopPlan() {
        return liquidLoopPlan;
    }

    public void setLiquidLoopPlan(LiquidLoopPlan liquidLoopPlan) {
        this.liquidLoopPlan = liquidLoopPlan;
    }

    public ChangeLiquidBO getChangeLiquidBO() {
        return changeLiquidBO;
    }

    public void setChangeLiquidBO(ChangeLiquidBO changeLiquidBO) {
        this.changeLiquidBO = changeLiquidBO;
    }

    public int getCurrentChangeIndex() {
        return currentChangeIndex;
    }

    public void setCurrentChangeIndex(int currentChangeIndex) {
        this.currentChangeIndex = currentChangeIndex;
    }

    public int getCurrentChangeTurn() {
        return currentChangeTurn;
    }

    public void setCurrentChangeTurn(int currentChangeTurn) {
        this.currentChangeTurn = currentChangeTurn;
    }

    public int getTotalTurn(){
        if(changeLiquidBO==null||changeLiquidBO.getChangeLiquidTurnList()==null){
            return 0;
        }else {
            return changeLiquidBO.getChangeLiquidTurnList().size();
        }
    }

    public int getTotalTimes(int turn){
        return changeLiquidBO.getChangeLiquidTurnList().get(turn-1).getAmountList().size();
    }

    public Thread getThread() {
        return thread;
    }

    public void setThread(Thread thread) {
        this.thread=thread;
    }

//    public int getCurrentAmount() {
//        return getAmount(currentChangeTurn,currentChangeIndex);
//    }

    public int getWasteCurrentAmount() {
        return getWasteAmount(currentChangeTurn,currentChangeIndex);
    }

    public int getFluidCurrentAmount() {
        return getFluidAmount(currentChangeTurn,currentChangeIndex);
    }

//    public int getAmount(int turn,int index) {
//        return changeLiquidBO.getChangeLiquidTurnList().get(turn-1).getAmountList().get(index-1);
//    }
//
    public int getWasteAmount(int turn,int index) {
        return changeLiquidBO.getWasteAmountByTurnIndex(turn,index);
    }

    public int getFluidAmount(int turn,int index) {
        return changeLiquidBO.getFluidAmountByTurnIndex(turn,index);
    }

    public int getLiquidType() {
        return liquidType;
    }

    public void setLiquidType(@LiquidLoopTask.LiquidType int liquidType) {
        this.liquidType = liquidType;
    }

    public boolean isTerminate() {
        return isTerminate;
    }

    public void setTerminate(boolean terminate) {
        isTerminate = terminate;
    }
}
